package com.itheima.reggie.common;

/**
 * @Author: King-lby
 * @Date Created in 2022-11-01 17:39
 */

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前用户登录的id
 */
public class BaseContext {//以线程为作用域
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    //设置
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }
    //获取
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
